import { baseUrl } from './url'
const KEY = "be28a3e23ed54c689ebff7eb56e44c5f"


var http = {
  get(url, data) {
    return new Promise((resolve, reject) => {
      data.key = KEY
      wx.request({
        url: baseUrl + url, 
        data: data,
        method: 'Get',
        success (res) {
          resolve(res)
        },
        fail (err) {
          console.log("页面请求数据失败")
          reject(err)
        }
      })
    })
  },
  post (url, data) {
    return new Promise((resolve, reject) => {
      data.key = KEY
      wx.request({
        url: baseUrl + url, 
        data: data,
        method: 'POST',
        header: {
          'content-type': 'application/json'
        },
        success (res) {
          resolve(res.data)
        },
        fail (err) {
          console.log("页面请求数据失败")
          reject(err)
        }
      })
    })
  }
}

export default http

